/*============注册手机号===================*/
document.querySelector(".username").onblur = checkUsername;
function checkUsername(){
    var username = document.querySelector(".username").value;
    if(username == ""||username ==null){
        document.querySelector(".username-msg").innerText="手机号不能为空";
        return false;
    }else if(!/^1(3\d|4[5-9]|5[0-35-9]|6[567]|7[0-8]|8\d|9[0-35-9])\d{8}$/.test(username)){
        document.querySelector(".username-msg").innerText="请输入正确的手机号";
        return false;
    }else{
        document.querySelector(".username-msg").innerText="";
        return true;
    }
}

/*===============密码=================*/
document.querySelector(".register-password").onblur = checkPassword;
function checkPassword(){
    var password1=document.querySelector(".register-password").value;


    if (password1== ""||password1 ==null){
        document.querySelector(".register-password-msg").innerText="密码不能为空";

    }else if(!/^[\w_-]{6,16}$/.test(password1)){
        document.querySelector(".register-password-msg").innerText="请输入正确的密码";
    }else{
        document.querySelector(".register-password-msg").innerText="";
    }

}
/*=================再次确认密码v==========================*/
document.querySelector(".register-password2").onblur = function (){
    var password1=document.querySelector(".register-password").value;
    var password2=document.querySelector(".register-password2").value;
    if (password2== ""||password2 ==null){
        document.querySelector(".register-password-msg2").innerText="请再次输入密码";

    }else if(password2!=password1){
        document.querySelector(".register-password-msg2").innerText="密码于之前不一致";
    }else{
        document.querySelector(".register-password-msg2").innerText="";
    }
}
/*============注册=====================*/
document.querySelector(".register-btn-popup").onclick =  function () {
    //用户名
    var username = document.querySelector(".username").value;
    console.log("用户名：" + username);
    //密码
    var password1 = document.querySelector(".register-password").value;
    console.log("密码：" + password1);

    //确认密码
    var password2 = document.querySelector(".register-password2").value;
    console.log("确认密码：" + password2);
}
document.querySelector(".registForm").onsubmit= function (){
    return checkUsername() && checkPassword();//  return true / return false;
}
